*****************************************************************************************************************************************
// HAITI LOTTO-SAVINGS EXPERIMENTS
// MAIN ANALYSIS REPLICATION
// Felipe Dizon & Travis Lybbert
// July 2019
*****************************************************************************************************************************************

/* NOTES

Datasets used: 
llsa_analysis_1.dta (wide form), and llsa_analysis_2.dta (long form)

Outline:
Descriptives table (table 2)
Comparison of means (table 3 and figure 1)
Part 1: effect of llsa on total savings (table 4)
Part 2: effect of llsa on other financial products (table 5)
Part 3: heterogeneous effects of llsa (tables 6 and 7)

*/


clear all
clear matrix
clear mata
set more off

cd "/Users/felipedizon/Dropbox/Research/lottery savings haiti/lab games/paper/submission_edcc/ForPublication/Replication"

	
// DESCRIPTIVES
***********************************************************************************************************************************	

use "llsa_analysis_1.dta", replace
	
	// table 2: descriptive statistics
	
	replace s_civilstatus=0 if s_civilstatus==2
	gen s_student=(s_occupation==1)
	replace s_student=. if s_occupation==.
	gen s_unemployed=(s_occupation==7 & s_occupation!=.)
	replace s_unemployed=. if s_occupation==.
	
	gen game1_cons_p=game1_cons/300
	gen game1_loto_p=game1_loto/300
	gen game1_save_p=game1_save/300
	
		// xxx cannot get a decent loto by income measure
		gen xloto1=s_loto_wagertotamt*s_loto_dayswk
		gen xloto2=xloto1/s_income_wk
		replace xloto2=1 if s_income_wk==0 & s_loto_wagertotamt!=. & s_loto_wagertotamt==0
	
	preserve
	drop if prac1_cons==.
	
	gl H "table2"
	
	estpost summarize ///
	s_age s_gender s_hhsize s_civilstatus s_student s_unemployed ///
	s_income_wk s_spendfood_mt ///
	s_hfias_anxiety s_hfias_none s_hfias_sleephungry s_hfias_nonewholeday ///
	s_assets_refri s_assets_flushtoilet ///
	s_loto_dayswk s_loto_wagertotamt s_playloto_mobile ///
	s_playloto_fun s_playloto_forinvest s_playloto_goal s_playloto_dreams s_playloto_social ///
	s_save_sol s_save_bank s_save_bank_amt s_save_informal s_save_informal_amt ///
	s_credit_family s_credit_family_amt ///
	sigma alpha game1_cons_p game1_loto_p game1_save_p
	eststo esttotal
	
	#delimit ;
	
	esttab esttotal using "${H}", replace tex 
	cells("mean(fmt(a2)) sd count") label nodepvar nostar unstack 
	varlabel(s_age "Age" s_gender "Male" s_hhsize "Household size" s_civilstatus "Single" s_student "Student" s_unemployed "Unemployed" 
	s_income_wk "Income, one week" s_spendfood_mt "Food expenses, one month" 
	s_hfias_anxiety "Food security (1): anxiety about HH food"
	s_hfias_none "Food security (2): no food in HH"
	s_hfias_sleephungry "Food security (3): slept at night hungry"
	s_hfias_nonewholeday "Food security (4): whole day without eating"
	s_assets_refri "Has refrigerator" s_assets_flushtoilet "Has flush toilet" 
	s_loto_dayswk "Days per week play lotto" s_loto_wagertotamt "Bet amount on a usual day" s_playloto_mobile "Ever played lotto on mobile phone"
	s_playloto_fun "Play lotto: for fun" s_playloto_forinvest  "Play lotto: for investment" s_playloto_goal  "Play lotto: for goal" s_playloto_dreams  "Play lotto: for dreams" s_playloto_social  "Play lotto: social"
	s_save_sol "Save in sol" 
	s_save_bank "Save in bank" s_save_bank_amt "Save: balance in bank" 
	s_save_informal "Save informally (at home or with neighbor or friend)" s_save_informal_amt "Save: balance in informal" 
	s_credit_family "Borrowed money from family" s_credit_family_amt "Outstanding credit balance from family" 
	sigma "Risk aversion parameter" alpha "Prelec probability weighting parameter"
	game1_cons_p "Round 1: allocation to consumption" game1_loto_p "Round 1: allocation to lotto" game1_save_p "Round 1: allocation to savings") 
	addnotes("Notes: All currency amounts are in HTG. The food security measures are yes and no responses to the following questions, 
	(1) In the past 4 weeks, did you worry that your household would not have enough food?, 
	(2) In the past 4 weeks, was there ever no food at all in your household because there were no resources to get more?
	(3) In the past 4 weeks, did you or any household member go to sleep at night hungry because there was not enough food?
	(4) In the past 4 weeks, did you or any household member go a whole day without eating anything because there was not enough food?"); 	
	
	#delimit cr
	
	restore
	
	
	
use "llsa_analysis_2.dta", replace
		
	// PANEL SET-UP
	xtset PIDX game
	
	
// COMPARISON OF MEANS
**********************************************************************************************************************************************************

	// table 3: portfolio allocation across games
	
	gl H "table3"
	
		// generate new variables
		// proportion any savings, and proportion who reached maximum savings
		
		gen anysave=cond(save!=0 | (llsa!=0 & (game==3 | game==4 | game==5 | game==6)), 1, 0)
		gen maxsave=cond(save==300, 1, 0)
		
		// share of total
		
		gen cons_s=cons/300
		gen loto_s=loto/300
		gen save_s=save/300
		gen llsa_s=llsa/300
		
		***
		
	bys game: eststo: estpost summarize ///
	cons_s loto_s save_s llsa_s ///
	cons loto save llsa anysave maxsave
	
	#delimit ;
	
	esttab est4 est5 est6 est7 est8 est9 using "${H}", replace tex 
	main(mean) aux(sd) label nodepvar nostar 
	varlabel(cons_s "Consumption" loto_s "Lotto" save_s "Savings" llsa_s "LLS"
	cons "Consumption" loto "Lotto" save "Savings" llsa "LLS") 
	mlabels ("Round 1, Interest 5\%, No LLS" "Round 2, Interest 20\%, No LLS" 
	"Round 3, Interest 5\%, LLS: principal 65\% + lotto 50\%" "Round 4, Interest 5\%, LLS: principal 80\% + lotto 50\%" 
	"Round 5, Interest 5\%, LLS: principal 85\% + lotto 25\%" "Round 6, Interest 20\%, LLS: principal 100\% + lotto 25\%") 
	addnotes("Notes: This table presents mean allocation into each offered financial product across each of the rounds. 
	Panel A presents the share of the endowment allocated, while panel B presents the amount of the endowment allocated.
	Standard deviations are reported in parentheses.
	Round 1 and 2 are games where LLS was not offered, while rounds 3 to 6 include LLS in various forms.
	Saved any refers to proportion of sample which allocated any amount to the savings or llsa financial product, 
	and Saved max refers to the proportion of sample which allocated the entire amount to the savings product."); 	
	
	#delimit cr
	
	// figure 1: comparison of savings mean across games
	
	preserve
	drop if game==101 | game==102 | game==103
	
	
	#delimit ;
	cibar tlsave, over1(game) 
	level(95) ciopts(lwidth(thin) msize(small) lcolor(black))
	bargap(2) barcolor(gs13 gs13 gs7 gs7 gs7 gs7)
	graphopts(
	yscale(range(0,200)) ytick(0(20)200) ylabel(0(20)200)
	graphregion(color(white)) 
	ytitle("Total Savings")
	legend(off)
	note("Notes: Each bar represents the mean of total savings in each decision round. Total savings is defined as" 
	"the total secured principal received in eight weeks, which equals the sum of the amount allocated to savings"
	"(excluding interest) and the amount allocated to LLS which will be paid back with certainty (excluding lotto"
	"winnings). The darker bars represent rounds where LLS was offered (rounds 3-6). The bands indicate a 95%"
	"confidence interval for the calculated mean.", size(small))); 
	#delimit cr
	
	graph export "figure1.png", as(png) replace
	
	restore

**********************************************************************************************************************************************************
// PART 1: effect of llsa on total savings
// Does an llsa increase total savings?
// What product calibration matters? (experimental)
**********************************************************************************************************************************************************

	gl H1 "table4"
	
	gl replications "5"
	*gl replications "500"
	
	// 1a) main effect: delayed amount
	****************************************************************************
	
	gen withllsa=cond(game==3 | game==4 | game==5 | game==6, 1, 0)
	

	// temp
		gen tlsave12=tlsave if game==1 | game==2
		bysort PIDX: egen tlsave12x=mean(tlsave12) // mean may not be ideal
		gen llsa_basesave=withllsa*tlsave12x
		
	
		*****
		
	// main
	xtreg tlsave withllsa if game<100, fe vce(cl PIDX)
	qui sum tlsave if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	
	matrix main=(`pchng')
	matrix li main
	
	// replications 
	capture program drop boot_percentages
	program define boot_percentages, eclass
	preserve 
	bsample
		xtreg tlsave withllsa if game<100, fe vce(cl PIDX) 
		qui sum tlsave if withllsa==0 & game<100
		estadd scalar Ymean = r(mean)
		
		local Ymean = r(mean)
		mat X = e(b)
		local atecoeff = el(X,1,1)
		estadd scalar xpchng = (`atecoeff'/`Ymean')*100
		ereturn scalar zpchng=e(xpchng)
		
	restore
	end
	
	preserve
	simulate zpchng=e(xpchng), reps($replications) seed(12345): boot_percentages
	bstat, stat(main)
	restore
	
	mat B= r(table)
	local se1=el(B,2,1) 
	
	// main (save output)
	xtreg tlsave withllsa if game<100, fe vce(cl PIDX) 
	qui sum tlsave if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	
	estadd scalar se1 = `se1'
	
	eststo est1a

	
	// 1b) with certain interest	
	****************************************************************************
	
	// main
	xtreg tlsave_i withllsa if game<100, fe vce(cl PIDX) 
	qui sum tlsave_i if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	
	matrix main=(`pchng')
	matrix li main
	
	// replications 
	capture program drop boot_percentages
	program define boot_percentages, eclass
	preserve 
	bsample
		xtreg tlsave_i withllsa if game<100, fe vce(cl PIDX) 
		qui sum tlsave_i if withllsa==0 & game<100
		estadd scalar Ymean = r(mean)
		
		local Ymean = r(mean)
		mat X = e(b)
		local atecoeff = el(X,1,1)
		estadd scalar xpchng = (`atecoeff'/`Ymean')*100
		ereturn scalar zpchng=e(xpchng)
		
	restore
	end
	
	preserve
	simulate zpchng=e(xpchng), reps($replications) seed(12345): boot_percentages
	bstat, stat(main)
	restore
	
	mat B= r(table)
	local se1=el(B,2,1) 
	
	// main (save output)
	xtreg tlsave_i withllsa if game<100, fe vce(cl PIDX) 
	qui sum tlsave_i if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	
	estadd scalar se1 = `se1'
	
	eststo est1b

		
	// 1c) with certain interest and uncertain lotto payouts 
	****************************************************************************
	
	// main
	xtreg tlsave_iew withllsa if game<100, fe vce(cl PIDX) 
	qui sum tlsave_iew if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	
	matrix main=(`pchng')
	matrix li main
	
	// replications 
	capture program drop boot_percentages
	program define boot_percentages, eclass
	preserve 
	bsample
		xtreg tlsave_iew withllsa if game<100, fe vce(cl PIDX) 
		qui sum tlsave_iew if withllsa==0 & game<100
		estadd scalar Ymean = r(mean)
		
		local Ymean = r(mean)
		mat X = e(b)
		local atecoeff = el(X,1,1)
		estadd scalar xpchng = (`atecoeff'/`Ymean')*100
		ereturn scalar zpchng=e(xpchng)
		
	restore
	end
	
	preserve
	simulate zpchng=e(xpchng), reps($replications) seed(12345): boot_percentages
	bstat, stat(main)
	restore
	
	mat B= r(table)
	local se1=el(B,2,1) 
	
	// main (save output)
	xtreg tlsave_iew withllsa if game<100, fe vce(cl PIDX) 
	qui sum tlsave_iew if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	
	estadd scalar se1 = `se1'
	
	eststo est1c
	
	// 1 ereturn a) total expected portfolio return
	****************************************************************************
	
	xtreg ereturn withllsa if game<100, fe
	
	qui sum ereturn if withllsa==0 & game<100
	local Ymean = r(mean)
	mat X = e(b)
	local atecoeff = el(X,1,1)
	local pchng = `atecoeff'/`Ymean'
	estadd scalar pchng = `pchng'*100
	eststo est1_ereturn_a
	
	
	// BY features of llsa and savings
	****************************************************************************
	
		// lotto-intensity of llsa (34-high to 56-low) 
		// aside: ordering of lotto-intensity of llsa
		gen lowriskllsa=cond(game==5 | game==6, 1, 0)
		gen withllsa_lowriskllsa=withllsa*lowriskllsa
		
		// return of llsa vs savings (AM- =savings to PM- <savings)
		gen lowretllsa=cond(session==2, 1, 0)
		gen withllsa_lowretllsa=withllsa*lowretllsa
	
		// interest rate on savings (35-low to 46-high)
		gen hiintsave=cond(game==2 | game==4 | game==6, 1, 0)
		gen withllsa_hiintsave=withllsa*hiintsave
	
			// ASIDE: effect of high interest (comparing round 2-4-6 to 1-3-5)
			xtreg tlsave hiintsave if game<100, fe vce(cl PIDX) 
			qui sum tlsave if hiintsave==0 & game<100
			estadd scalar Ymean = r(mean)
			local Ymean = r(mean)
			mat X = e(b)
			mat li X
			local atecoeff = el(X,1,1)
			local pchng = (`atecoeff'/`Ymean')*100
			estadd scalar pchng = `pchng'
			// percentage effect=11.6%
		
	
	// 1d) main effect: delayed amount
	****************************************************************************
	
	// main
	xtreg tlsave withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	qui sum tlsave if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	local atecoeff_x = el(X,1,2)
	local atecoeff_a= `atecoeff' + `atecoeff_x'
	local pchng_a = (`atecoeff_a'/`Ymean')*100
	local atecoeff_xx = el(X,1,3)
	local atecoeff_b= `atecoeff' + `atecoeff_xx'
	local pchng_b = (`atecoeff_b'/`Ymean')*100
	local atecoeff_xxx = el(X,1,5)
	local atecoeff_c= `atecoeff' + `atecoeff_xxx'
	local pchng_c = (`atecoeff_c'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	estadd scalar pchng_a = `pchng_a'
	estadd scalar pchng_b = `pchng_b'
	estadd scalar pchng_c = `pchng_c'
	
	matrix main=(`pchng', `pchng_a', `pchng_b', `pchng_c')
	matrix li main
	
	// replications 
	capture program drop boot_percentages
	program define boot_percentages, eclass
	preserve 
	bsample
		xtreg tlsave withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
		qui sum tlsave if withllsa==0 & game<100
		estadd scalar Ymean = r(mean)
		
		local Ymean = r(mean)
		mat X = e(b)
		local atecoeff = el(X,1,1)
		estadd scalar xpchng = (`atecoeff'/`Ymean')*100
		ereturn scalar zpchng=e(xpchng)
		
		local atecoeff_x = el(X,1,2)
		local atecoeff_a= `atecoeff' + `atecoeff_x'
		estadd scalar xpchng_a = (`atecoeff_a'/`Ymean')*100
		ereturn scalar zpchng_a=e(xpchng_a)
		
		local atecoeff_xx = el(X,1,3)
		local atecoeff_b= `atecoeff' + `atecoeff_xx'
		estadd scalar xpchng_b = (`atecoeff_b'/`Ymean')*100
		ereturn scalar zpchng_b=e(xpchng_b)
		
		local atecoeff_xxx = el(X,1,5)
		local atecoeff_c= `atecoeff' + `atecoeff_xxx'
		estadd scalar xpchng_c = (`atecoeff_c'/`Ymean')*100
		ereturn scalar zpchng_c=e(xpchng_c)
		
	restore
	end
	
	preserve
	simulate zpchng=e(xpchng) zpchng_a=e(xpchng_a) zpchng_b=e(xpchng_b) zpchng_c=e(xpchng_c), reps($replications) seed(12345): boot_percentages
	bstat, stat(main)
	restore
	
	mat B= r(table)
	local se1=el(B,2,1) 
	local se2=el(B,2,2)
	local se3=el(B,2,3)
	local se4=el(B,2,4)
	
	// main (save output)
	xtreg tlsave withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	qui sum tlsave if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	local atecoeff_x = el(X,1,2)
	local atecoeff_a= `atecoeff' + `atecoeff_x'
	local pchng_a = (`atecoeff_a'/`Ymean')*100
	local atecoeff_xx = el(X,1,3)
	local atecoeff_b= `atecoeff' + `atecoeff_xx'
	local pchng_b = (`atecoeff_b'/`Ymean')*100
	local atecoeff_xxx = el(X,1,5)
	local atecoeff_c= `atecoeff' + `atecoeff_xxx'
	local pchng_c = (`atecoeff_c'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	estadd scalar pchng_a = `pchng_a'
	estadd scalar pchng_b = `pchng_b'
	estadd scalar pchng_c = `pchng_c'
	
	estadd scalar se1 = `se1'
	estadd scalar se2 = `se2'
	estadd scalar se3 = `se3'
	estadd scalar se4 = `se4'
	
	eststo est1d
	
	// 1e) with certain interest
	****************************************************************************
	
	// main
	xtreg tlsave_i withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	
	qui sum tlsave_i if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	local atecoeff_x = el(X,1,2)
	local atecoeff_a= `atecoeff' + `atecoeff_x'
	local pchng_a = (`atecoeff_a'/`Ymean')*100
	local atecoeff_xx = el(X,1,3)
	local atecoeff_b= `atecoeff' + `atecoeff_xx'
	local pchng_b = (`atecoeff_b'/`Ymean')*100
	local atecoeff_xxx = el(X,1,5)
	local atecoeff_c= `atecoeff' + `atecoeff_xxx'
	local pchng_c = (`atecoeff_c'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	estadd scalar pchng_a = `pchng_a'
	estadd scalar pchng_b = `pchng_b'
	estadd scalar pchng_c = `pchng_c'
	
	matrix main=(`pchng', `pchng_a', `pchng_b', `pchng_c')
	matrix li main
	
	// replications 
	capture program drop boot_percentages
	program define boot_percentages, eclass
	preserve 
	bsample
		xtreg tlsave_i withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
		qui sum tlsave_i if withllsa==0 & game<100
		estadd scalar Ymean = r(mean)
		
		local Ymean = r(mean)
		mat X = e(b)
		local atecoeff = el(X,1,1)
		estadd scalar xpchng = (`atecoeff'/`Ymean')*100
		ereturn scalar zpchng=e(xpchng)
		
		local atecoeff_x = el(X,1,2)
		local atecoeff_a= `atecoeff' + `atecoeff_x'
		estadd scalar xpchng_a = (`atecoeff_a'/`Ymean')*100
		ereturn scalar zpchng_a=e(xpchng_a)
		
		local atecoeff_xx = el(X,1,3)
		local atecoeff_b= `atecoeff' + `atecoeff_xx'
		estadd scalar xpchng_b = (`atecoeff_b'/`Ymean')*100
		ereturn scalar zpchng_b=e(xpchng_b)
		
		local atecoeff_xxx = el(X,1,5)
		local atecoeff_c= `atecoeff' + `atecoeff_xxx'
		estadd scalar xpchng_c = (`atecoeff_c'/`Ymean')*100
		ereturn scalar zpchng_c=e(xpchng_c)
		
	restore
	end
	
	preserve
	simulate zpchng=e(xpchng) zpchng_a=e(xpchng_a) zpchng_b=e(xpchng_b) zpchng_c=e(xpchng_c), reps($replications) seed(12345): boot_percentages
	bstat, stat(main)
	restore
	
	mat B= r(table)
	local se1=el(B,2,1) 
	local se2=el(B,2,2)
	local se3=el(B,2,3)
	local se4=el(B,2,4)
	
	// main (save output)
	xtreg tlsave_i withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	qui sum tlsave_i if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	local atecoeff_x = el(X,1,2)
	local atecoeff_a= `atecoeff' + `atecoeff_x'
	local pchng_a = (`atecoeff_a'/`Ymean')*100
	local atecoeff_xx = el(X,1,3)
	local atecoeff_b= `atecoeff' + `atecoeff_xx'
	local pchng_b = (`atecoeff_b'/`Ymean')*100
	local atecoeff_xxx = el(X,1,5)
	local atecoeff_c= `atecoeff' + `atecoeff_xxx'
	local pchng_c = (`atecoeff_c'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	estadd scalar pchng_a = `pchng_a'
	estadd scalar pchng_b = `pchng_b'
	estadd scalar pchng_c = `pchng_c'
	
	estadd scalar se1 = `se1'
	estadd scalar se2 = `se2'
	estadd scalar se3 = `se3'
	estadd scalar se4 = `se4'
	
	eststo est1e
	
	// 1f) with certain interest and uncertain lotto payouts 
	****************************************************************************
	
	// main
	xtreg tlsave_iew withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	qui sum tlsave_i if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	local atecoeff_x = el(X,1,2)
	local atecoeff_a= `atecoeff' + `atecoeff_x'
	local pchng_a = (`atecoeff_a'/`Ymean')*100
	local atecoeff_xx = el(X,1,3)
	local atecoeff_b= `atecoeff' + `atecoeff_xx'
	local pchng_b = (`atecoeff_b'/`Ymean')*100
	local atecoeff_xxx = el(X,1,5)
	local atecoeff_c= `atecoeff' + `atecoeff_xxx'
	local pchng_c = (`atecoeff_c'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	estadd scalar pchng_a = `pchng_a'
	estadd scalar pchng_b = `pchng_b'
	estadd scalar pchng_c = `pchng_c'
	
	matrix main=(`pchng', `pchng_a', `pchng_b', `pchng_c')
	matrix li main
	
	// replications 
	capture program drop boot_percentages
	program define boot_percentages, eclass
	preserve 
	bsample
		xtreg tlsave_iew withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
		qui sum tlsave_iew if withllsa==0 & game<100
		estadd scalar Ymean = r(mean)
		
		local Ymean = r(mean)
		mat X = e(b)
		local atecoeff = el(X,1,1)
		estadd scalar xpchng = (`atecoeff'/`Ymean')*100
		ereturn scalar zpchng=e(xpchng)
		
		local atecoeff_x = el(X,1,2)
		local atecoeff_a= `atecoeff' + `atecoeff_x'
		estadd scalar xpchng_a = (`atecoeff_a'/`Ymean')*100
		ereturn scalar zpchng_a=e(xpchng_a)
		
		local atecoeff_xx = el(X,1,3)
		local atecoeff_b= `atecoeff' + `atecoeff_xx'
		estadd scalar xpchng_b = (`atecoeff_b'/`Ymean')*100
		ereturn scalar zpchng_b=e(xpchng_b)
		
		local atecoeff_xxx = el(X,1,5)
		local atecoeff_c= `atecoeff' + `atecoeff_xxx'
		estadd scalar xpchng_c = (`atecoeff_c'/`Ymean')*100
		ereturn scalar zpchng_c=e(xpchng_c)
		
	restore
	end
	
	preserve
	simulate zpchng=e(xpchng) zpchng_a=e(xpchng_a) zpchng_b=e(xpchng_b) zpchng_c=e(xpchng_c), reps($replications) seed(12345): boot_percentages
	bstat, stat(main)
	restore
	
	mat B= r(table)
	local se1=el(B,2,1) 
	local se2=el(B,2,2)
	local se3=el(B,2,3)
	local se4=el(B,2,4)
	
	// main (save output)
	xtreg tlsave_iew withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	qui sum tlsave_iew if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	local atecoeff_x = el(X,1,2)
	local atecoeff_a= `atecoeff' + `atecoeff_x'
	local pchng_a = (`atecoeff_a'/`Ymean')*100
	local atecoeff_xx = el(X,1,3)
	local atecoeff_b= `atecoeff' + `atecoeff_xx'
	local pchng_b = (`atecoeff_b'/`Ymean')*100
	local atecoeff_xxx = el(X,1,5)
	local atecoeff_c= `atecoeff' + `atecoeff_xxx'
	local pchng_c = (`atecoeff_c'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	estadd scalar pchng_a = `pchng_a'
	estadd scalar pchng_b = `pchng_b'
	estadd scalar pchng_c = `pchng_c'
	
	estadd scalar se1 = `se1'
	estadd scalar se2 = `se2'
	estadd scalar se3 = `se3'
	estadd scalar se4 = `se4'
	
	eststo est1f
	
	// 1 ereturn b) total expected portfolio return
	****************************************************************************
	
	xtreg ereturn withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	
	qui sum ereturn if withllsa==0 & game<100
	local Ymean = r(mean)
	mat X = e(b)
	local atecoeff = el(X,1,1)
	local pchng = `atecoeff'/`Ymean'
	local atecoeff_x = el(X,1,2)
	local atecoeff_a= `atecoeff' + `atecoeff_x'
	local pchng_a = `atecoeff_a'/`Ymean'
	local atecoeff_xx = el(X,1,3)
	local atecoeff_b= `atecoeff' + `atecoeff_xx'
	local pchng_b = `atecoeff_b'/`Ymean'
	local atecoeff_xxx = el(X,1,5)
	local atecoeff_c= `atecoeff' + `atecoeff_xxx'
	local pchng_c = `atecoeff_c'/`Ymean'
	
	estadd scalar pchng = `pchng'*100
	estadd scalar pchng_a = `pchng_a'*100
	estadd scalar pchng_b = `pchng_b'*100
	estadd scalar pchng_c = `pchng_c'*100
	eststo est1_ereturn_b
	
		// aside: explore order effects
		xtreg tlsave withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave order if game<100, fe vce(cl PIDX) 
		xtreg tlsave withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave logorder if game<100, fe vce(cl PIDX) 
	
	
	// output (savings)
	#delimit ;
	esttab est1a est1b est1c est1d est1e est1f using "${H1}", replace tex 							
	b(1) se(1) star(* 0.10 ** 0.05 *** 0.01)  		 					    	    
	stats(pchng se1 pchng_a se2 pchng_b se3 pchng_c se4 N N_g Ymean, 
	labels("(a) LLS" " " "(a+b) LLS- low risk" " " "(a+c) LLS- low return" " " "(a+e) LLS- high interest" " " 
	"Observations" "Participants" "Mean, LLS not offered")) drop()      
	varlabel(withllsa "(a) LLS offered" 
	withllsa_lowriskllsa "(b) Low Risk LLS" withllsa_lowretllsa "(c) Low Return LLS" 
	hiintsave "(d) High Interest Savings" withllsa_hiintsave "(e) LLS $\times$ High Interest Savings"
	_cons "Mean, LLS not offered") 
	mlabels ("Savings" "Savings + Interest" "Savings + Interest + E(winnings)"  
	"Savings" "Savings + Interest" "Savings + Interest + E(winnings)") 
	nonotes addnotes("Notes: Total savings is defined as the total secured principal received in eight weeks, 
	which equals the sum of the amount allocated to savings (excluding interest) 
	and the amount allocated to LLS which will be paid back with certainty (excluding lotto winnings).
	Individual fixed effects are included in the regressions. 
	Robust standard errors clustered by individuals are shown in parentheses below the point estimates. 
	Level of significance: *** p<0.01, ** p<0.05, * p<0.10.
	Bootstrapped standard errors, using 500 replications, are shown in brackets below the effect sizes in percent.");			
	#delimit cr
	
	*/
	
**********************************************************************************************************************************************************
// PART 2: effect of llsa on other financial products
// If llsa increases savings, where is it coming from?
**********************************************************************************************************************************************************
	
	gl H1 "table5a"
	gl H2 "table5b"
	gl H3 "table5c"
	
	gen avg_cons_300=cons/300
	gen avg_loto_300=loto/300
	gen avg_save_300=save/300
	
	gen sum_nonllsa=cons+loto+save
	gen avg_cons_nonllsa=cons/sum_nonllsa
	gen avg_loto_nonllsa=loto/sum_nonllsa
	gen avg_save_nonllsa=save/sum_nonllsa
	
	// 2a) consumption 
	****************************************************************************
	
	// main
	xtreg cons withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	qui sum cons if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	local atecoeff_x = el(X,1,2)
	local atecoeff_a= `atecoeff' + `atecoeff_x'
	local pchng_a = (`atecoeff_a'/`Ymean')*100
	local atecoeff_xx = el(X,1,3)
	local atecoeff_b= `atecoeff' + `atecoeff_xx'
	local pchng_b = (`atecoeff_b'/`Ymean')*100
	local atecoeff_xxx = el(X,1,5)
	local atecoeff_c= `atecoeff' + `atecoeff_xxx'
	local pchng_c = (`atecoeff_c'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	estadd scalar pchng_a = `pchng_a'
	estadd scalar pchng_b = `pchng_b'
	estadd scalar pchng_c = `pchng_c'
	
	matrix main=(`pchng', `pchng_a', `pchng_b', `pchng_c')
	matrix li main
	
	// replications 
	capture program drop boot_percentages
	program define boot_percentages, eclass
	preserve 
	bsample
		xtreg cons withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
		qui sum cons if withllsa==0 & game<100
		estadd scalar Ymean = r(mean)
		
		local Ymean = r(mean)
		mat X = e(b)
		local atecoeff = el(X,1,1)
		estadd scalar xpchng = (`atecoeff'/`Ymean')*100
		ereturn scalar zpchng=e(xpchng)
		
		local atecoeff_x = el(X,1,2)
		local atecoeff_a= `atecoeff' + `atecoeff_x'
		estadd scalar xpchng_a = (`atecoeff_a'/`Ymean')*100
		ereturn scalar zpchng_a=e(xpchng_a)
		
		local atecoeff_xx = el(X,1,3)
		local atecoeff_b= `atecoeff' + `atecoeff_xx'
		estadd scalar xpchng_b = (`atecoeff_b'/`Ymean')*100
		ereturn scalar zpchng_b=e(xpchng_b)
		
		local atecoeff_xxx = el(X,1,5)
		local atecoeff_c= `atecoeff' + `atecoeff_xxx'
		estadd scalar xpchng_c = (`atecoeff_c'/`Ymean')*100
		ereturn scalar zpchng_c=e(xpchng_c)
		
	restore
	end
	
	preserve
	simulate zpchng=e(xpchng) zpchng_a=e(xpchng_a) zpchng_b=e(xpchng_b) zpchng_c=e(xpchng_c), reps($replications) seed(12345): boot_percentages
	bstat, stat(main)
	restore
	
	mat B= r(table)
	local se1=el(B,2,1) 
	local se2=el(B,2,2)
	local se3=el(B,2,3)
	local se4=el(B,2,4)
	
	// main (save output)
	xtreg cons withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	qui sum cons if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	local atecoeff_x = el(X,1,2)
	local atecoeff_a= `atecoeff' + `atecoeff_x'
	local pchng_a = (`atecoeff_a'/`Ymean')*100
	local atecoeff_xx = el(X,1,3)
	local atecoeff_b= `atecoeff' + `atecoeff_xx'
	local pchng_b = (`atecoeff_b'/`Ymean')*100
	local atecoeff_xxx = el(X,1,5)
	local atecoeff_c= `atecoeff' + `atecoeff_xxx'
	local pchng_c = (`atecoeff_c'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	estadd scalar pchng_a = `pchng_a'
	estadd scalar pchng_b = `pchng_b'
	estadd scalar pchng_c = `pchng_c'
	
	estadd scalar se1 = `se1'
	estadd scalar se2 = `se2'
	estadd scalar se3 = `se3'
	estadd scalar se4 = `se4'
	
	eststo est2a 
	
	// other specifications
	xtreg avg_cons_300 withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	eststo est2ax
	xtreg avg_cons_nonllsa withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	eststo est2axx
	
	// 2b) lottery
	****************************************************************************
	
	// main
	xtreg loto withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	qui sum loto if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	local atecoeff_x = el(X,1,2)
	local atecoeff_a= `atecoeff' + `atecoeff_x'
	local pchng_a = (`atecoeff_a'/`Ymean')*100
	local atecoeff_xx = el(X,1,3)
	local atecoeff_b= `atecoeff' + `atecoeff_xx'
	local pchng_b = (`atecoeff_b'/`Ymean')*100
	local atecoeff_xxx = el(X,1,5)
	local atecoeff_c= `atecoeff' + `atecoeff_xxx'
	local pchng_c = (`atecoeff_c'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	estadd scalar pchng_a = `pchng_a'
	estadd scalar pchng_b = `pchng_b'
	estadd scalar pchng_c = `pchng_c'
	
	matrix main=(`pchng', `pchng_a', `pchng_b', `pchng_c')
	matrix li main
	
	// replications 
	capture program drop boot_percentages
	program define boot_percentages, eclass
	preserve 
	bsample
		xtreg loto withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
		qui sum loto if withllsa==0 & game<100
		estadd scalar Ymean = r(mean)
		
		local Ymean = r(mean)
		mat X = e(b)
		local atecoeff = el(X,1,1)
		estadd scalar xpchng = (`atecoeff'/`Ymean')*100
		ereturn scalar zpchng=e(xpchng)
		
		local atecoeff_x = el(X,1,2)
		local atecoeff_a= `atecoeff' + `atecoeff_x'
		estadd scalar xpchng_a = (`atecoeff_a'/`Ymean')*100
		ereturn scalar zpchng_a=e(xpchng_a)
		
		local atecoeff_xx = el(X,1,3)
		local atecoeff_b= `atecoeff' + `atecoeff_xx'
		estadd scalar xpchng_b = (`atecoeff_b'/`Ymean')*100
		ereturn scalar zpchng_b=e(xpchng_b)
		
		local atecoeff_xxx = el(X,1,5)
		local atecoeff_c= `atecoeff' + `atecoeff_xxx'
		estadd scalar xpchng_c = (`atecoeff_c'/`Ymean')*100
		ereturn scalar zpchng_c=e(xpchng_c)
		
	restore
	end
	
	preserve
	simulate zpchng=e(xpchng) zpchng_a=e(xpchng_a) zpchng_b=e(xpchng_b) zpchng_c=e(xpchng_c), reps($replications) seed(12345): boot_percentages
	bstat, stat(main)
	restore
	
	mat B= r(table)
	local se1=el(B,2,1) 
	local se2=el(B,2,2)
	local se3=el(B,2,3)
	local se4=el(B,2,4)
	
	// main (save output)
	xtreg loto withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	qui sum loto if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	local atecoeff_x = el(X,1,2)
	local atecoeff_a= `atecoeff' + `atecoeff_x'
	local pchng_a = (`atecoeff_a'/`Ymean')*100
	local atecoeff_xx = el(X,1,3)
	local atecoeff_b= `atecoeff' + `atecoeff_xx'
	local pchng_b = (`atecoeff_b'/`Ymean')*100
	local atecoeff_xxx = el(X,1,5)
	local atecoeff_c= `atecoeff' + `atecoeff_xxx'
	local pchng_c = (`atecoeff_c'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	estadd scalar pchng_a = `pchng_a'
	estadd scalar pchng_b = `pchng_b'
	estadd scalar pchng_c = `pchng_c'
	
	estadd scalar se1 = `se1'
	estadd scalar se2 = `se2'
	estadd scalar se3 = `se3'
	estadd scalar se4 = `se4'
	
	eststo est2b
	
	// other specifications
	xtreg avg_loto_300 withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	eststo est2bx
	xtreg avg_loto_nonllsa withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	eststo est2bxx	
	
	// 2c) traditional savings
	****************************************************************************
	
	// main
	xtreg save withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	qui sum save if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	local atecoeff_x = el(X,1,2)
	local atecoeff_a= `atecoeff' + `atecoeff_x'
	local pchng_a = (`atecoeff_a'/`Ymean')*100
	local atecoeff_xx = el(X,1,3)
	local atecoeff_b= `atecoeff' + `atecoeff_xx'
	local pchng_b = (`atecoeff_b'/`Ymean')*100
	local atecoeff_xxx = el(X,1,5)
	local atecoeff_c= `atecoeff' + `atecoeff_xxx'
	local pchng_c = (`atecoeff_c'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	estadd scalar pchng_a = `pchng_a'
	estadd scalar pchng_b = `pchng_b'
	estadd scalar pchng_c = `pchng_c'
	
	matrix main=(`pchng', `pchng_a', `pchng_b', `pchng_c')
	matrix li main
	
	// replications 
	capture program drop boot_percentages
	program define boot_percentages, eclass
	preserve 
	bsample
		xtreg save withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
		qui sum save if withllsa==0 & game<100
		estadd scalar Ymean = r(mean)
		
		local Ymean = r(mean)
		mat X = e(b)
		local atecoeff = el(X,1,1)
		estadd scalar xpchng = (`atecoeff'/`Ymean')*100
		ereturn scalar zpchng=e(xpchng)
		
		local atecoeff_x = el(X,1,2)
		local atecoeff_a= `atecoeff' + `atecoeff_x'
		estadd scalar xpchng_a = (`atecoeff_a'/`Ymean')*100
		ereturn scalar zpchng_a=e(xpchng_a)
		
		local atecoeff_xx = el(X,1,3)
		local atecoeff_b= `atecoeff' + `atecoeff_xx'
		estadd scalar xpchng_b = (`atecoeff_b'/`Ymean')*100
		ereturn scalar zpchng_b=e(xpchng_b)
		
		local atecoeff_xxx = el(X,1,5)
		local atecoeff_c= `atecoeff' + `atecoeff_xxx'
		estadd scalar xpchng_c = (`atecoeff_c'/`Ymean')*100
		ereturn scalar zpchng_c=e(xpchng_c)
		
	restore
	end
	
	preserve
	simulate zpchng=e(xpchng) zpchng_a=e(xpchng_a) zpchng_b=e(xpchng_b) zpchng_c=e(xpchng_c), reps($replications) seed(12345): boot_percentages
	bstat, stat(main)
	restore
	
	mat B= r(table)
	local se1=el(B,2,1) 
	local se2=el(B,2,2)
	local se3=el(B,2,3)
	local se4=el(B,2,4)
	
	// main (save output)
	xtreg save withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	qui sum save if withllsa==0 & game<100
	estadd scalar Ymean = r(mean)
	
	local Ymean = r(mean)
	mat X = e(b)
	mat li X
	local atecoeff = el(X,1,1)
	local pchng = (`atecoeff'/`Ymean')*100
	local atecoeff_x = el(X,1,2)
	local atecoeff_a= `atecoeff' + `atecoeff_x'
	local pchng_a = (`atecoeff_a'/`Ymean')*100
	local atecoeff_xx = el(X,1,3)
	local atecoeff_b= `atecoeff' + `atecoeff_xx'
	local pchng_b = (`atecoeff_b'/`Ymean')*100
	local atecoeff_xxx = el(X,1,5)
	local atecoeff_c= `atecoeff' + `atecoeff_xxx'
	local pchng_c = (`atecoeff_c'/`Ymean')*100
	
	estadd scalar pchng = `pchng'
	estadd scalar pchng_a = `pchng_a'
	estadd scalar pchng_b = `pchng_b'
	estadd scalar pchng_c = `pchng_c'
	
	estadd scalar se1 = `se1'
	estadd scalar se2 = `se2'
	estadd scalar se3 = `se3'
	estadd scalar se4 = `se4'
	
	eststo est2c
	
	// other specifications
	xtreg avg_save_300 withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	eststo est2cx
	xtreg avg_save_nonllsa withllsa withllsa_lowriskllsa withllsa_lowretllsa hiintsave withllsa_hiintsave if game<100, fe vce(cl PIDX) 
	eststo est2cxx		
	
	
	****************************************************************************
	
	// output
	#delimit ;
	
	// amount
	esttab est2a est2b est2c using "${H1}", replace tex 							
	b(1) se(1) star(* 0.10 ** 0.05 *** 0.01)  		 					    	    
	stats(pchng se1 pchng_a se2 pchng_b se3 pchng_c se4 N N_g Ymean, 
	labels("(a) LLS" " " "(a+b) LLS- low risk" " " "(a+c) LLS- low return" " " "(a+e) LLS- high interest" " " 
	"Observations" "Participants" "Mean, LLS not offered")) drop()      
	varlabel(withllsa "(a) LLS offered" 
	withllsa_lowriskllsa "(b) Low Risk LLS" withllsa_lowretllsa "(c) Low Return LLS" 
	hiintsave "(d) High Interest Savings" withllsa_hiintsave "(e) LLS $\times$ High Interest Savings" 
	_cons "Mean, LLS not offered")  
	mlabels ("Consumption" "Lotto" "Traditional Savings") 
	nonotes addnotes("Notes: Dependent variables are amounts allocated to consumption, lotto, and traditional savings.
	Robust standard errors clustered by individuals are shown in parentheses below the point estimates. 
	Level of significance: *** p<0.01, ** p<0.05, * p<0.10.
	Bootstrapped standard errors, using 500 replications, are shown in brackets below the effect sizes in percent.");		
	
	// share of 300
	esttab est2ax est2bx est2cx using "${H2}", replace tex 							
	b(2) se(2) star(* 0.10 ** 0.05 *** 0.01)  		 					    	    
	stats(N, labels("Observations")) drop()      
	varlabel(withllsa "LLS offered") 
	mlabels ("Cons: Share of 300" "Loto: Share of 300" "TradSave: Share of 300") 
	nonotes addnotes("Notes:");	
	
	// share of non-lls
	esttab est2axx est2bxx est2cxx using "${H3}", replace tex 							
	b(2) se(2) star(* 0.10 ** 0.05 *** 0.01)  		 					    	    
	stats(N, labels("Observations")) drop()      
	varlabel(withllsa "LLS offered") 
	mlabels ("Cons: Share of Non-LLSA" "Loto: Share of Non-LLS" "TradSave: Share of Non-LLS") 
	nonotes addnotes("Notes:");	
	
	#delimit cr
	*/
	
**********************************************************************************************************************************************************
// PART 3: heterogeneous effects (from survey)
// What individual characteristics and preferences matter?
**********************************************************************************************************************************************************
	
	gl H1a "table6"
	gl H1b "table7"
	
	// 3a) survey measures and in-game measures
	*******************************************
	
	// wealth and poverty
	gen withllsa_wealth=withllsa*s_assetscore_pca2_std
	gen withllsa_spendfood=withllsa*s_spendfood_mt_std
	gen withllsa_hfias=withllsa*s_hfias_std
	gen withllsa_male=withllsa*s_gender
	
	gen withllsa_wealth2=withllsa*s_assetscore_pca2_nrm
	gen withllsa_spendfood2=withllsa*s_spendfood_mt_nrm
	gen withllsa_hfias2=withllsa*s_hfias_nrm
	
	
	// savings
	gen withllsa_savings=withllsa*s_totalsave_std
	 
	gen withllsa_save_sol=withllsa*s_save_sol_amt_std 
	gen withllsa_save_inf=withllsa*s_save_informal_amt_std 
	gen withllsa_save_bnk=withllsa*s_save_bank_amt_std 
	gen withllsa_save_mob=withllsa*s_save_mobile_amt_std 
	
	gen withllsa_savings2=withllsa*s_totalsave_nrm
	
	// lotto play
	gen withllsa_lotoplay=withllsa*s_loto_amt_wk_std
	
	gen withllsa_lotoplay2=withllsa*s_loto_amt_wk_nrm
	
		// within game savings, within game lotto play, within game interest sensitivity
		gen withllsa_pracsave=withllsa*prac_save
		gen withllsa_pracloto=withllsa*prac_loto
		
		gen withllsa_save12=withllsa*game12_tlsave_avg_std
		gen withllsa_loto12=withllsa*game12_loto_avg_std
		gen withllsa_save12diff=withllsa*game12_savediff
		
		gen withllsa_save122=withllsa*game12_tlsave_avg_nrm
		gen withllsa_loto122=withllsa*game12_loto_avg_nrm
	
	***
	
	xtreg tlsave withllsa withllsa_wealth withllsa_spendfood withllsa_hfias withllsa_male if game<100, fe vce(cl PIDX) 
	eststo est3a
	xtreg tlsave withllsa withllsa_savings withllsa_lotoplay if game<100, fe vce(cl PIDX) 
	eststo est3aa
	xtreg tlsave withllsa withllsa_save12 withllsa_loto12 if game<100, fe vce(cl PIDX)
	eststo est3aaa
	
	// 3b) time & risk preferences
	*******************************
	
	***************************************
	// replace alpha as negative
	replace alpha=-alpha
	replace alpha_std=-alpha_std
	replace alpha_nrm=-alpha_nrm
	***************************************
	
	// discount
	gen withllsa_discount=withllsa*s_discounta
	
	// present bias (hyperbolic discounting)
	gen withllsa_presbias=withllsa*s_presbias
	
	// sigma: risk aversion (positive sigma is used) ***
	gen withllsa_sigma=withllsa*sigma
	gen withllsa_sigma_std=withllsa*sigma_std
	
	gen withllsa_sigma_nrm=withllsa*sigma_nrm
	
	// alpha: prelec probability weighting (negative alpha is used) ***
	gen withllsa_alpha=withllsa*alpha
	gen withllsa_alpha_std=withllsa*alpha_std
	
	gen withllsa_alpha_nrm=withllsa*alpha_nrm
	
	// lack of formal financial services // transformational sum
	gen withllsa_lotoinvest=withllsa*s_playloto_forinvest 
	gen withllsa_lotogoal=withllsa*s_playloto_goal
	
	xtreg tlsave withllsa withllsa_discount withllsa_presbias if game<100, fe vce(cl PIDX) 
	eststo est3e
	xtreg tlsave withllsa withllsa_sigma_std withllsa_alpha_std if game<100, fe vce(cl PIDX) 
	eststo est3ee
			
	//
	
	// table 6
	#delimit ;
	esttab est3a est3aa est3aaa using "${H1a}", replace tex 							
	b(2) se(2) star(* 0.10 ** 0.05 *** 0.01)  		 					    	    
	stats(N N_g, labels("Observations" "Individuals")) drop()        
	varlabel(withllsa "LLS offered" withllsa_wealth "LLS offered $\times$ Wealth index" 
	withllsa_spendfood "LLS offered $\times$ Food expenses" withllsa_hfias "LLS offered $\times$ Food insecurity" 
	withllsa_male "LLS offered $\times$ Male"
	withllsa_savings "LLS offered $\times$ Savings" withllsa_lotoplay "LLS offered $\times$ Lotto spending" 
	withllsa_save12 "LLS offered $\times$ In-game savings"  withllsa_loto12  "LLS offered $\times$ In-game lotto"
	withllsa_discount "LLS offered $\times$ Discount rate" withllsa_presbias "LLS offered $\times$ Present bias" 
	withllsa_sigma_std "LLS offered $\times$ Risk loving" withllsa_alpha_std "LLS offered $\times$ Probability weighting"
	withllsa_lotoinvest "LLS offered $\times$ Play loto for investment" withllsa_lotogoal "LLS offered $\times$ Play loto for goal"
	_cons "Mean, LLS not offered") 
	mlabels ("Total savings" "Total savings" "Total savings" "Total savings" "Total savings")
	nonotes addnotes("Notes: Total savings is defined as the total secured principal received in eight weeks. 
	The following variables are transformed into its standard normal version: 
	wealth, food expenses, food insecurity, savings, lotto spending.
	In-game savings is the average savings in rounds 1 and 2, and in-game lotto is the average lotto spending in rounds 1 and 2. 
	In-game savings and in-game lotto are also transformed into its standard normal version. 
	Robust standard errors clustered by individuals are shown in parentheses. 
	Level of significance: *** p<0.01, ** p<0.05, * p<0.10.");	
	#delimit cr
	
	// table 7
	#delimit ;
	esttab est3e est3ee using "${H1b}", replace tex 							
	b(2) se(2) star(* 0.10 ** 0.05 *** 0.01)  		 					    	    
	stats(N N_g, labels("Observations" "Individuals")) drop()        
	varlabel(withllsa "LLS offered" withllsa_wealth "LLS offered $\times$ Wealth index" 
	withllsa_spendfood "LLS offered $\times$ Food expenses" withllsa_hfias "LLS offered $\times$ Food insecurity" 
	withllsa_male "LLS offered $\times$ Male"
	withllsa_savings "LLS offered $\times$ Savings" withllsa_lotoplay "LLS offered $\times$ Lotto spending" 
	withllsa_save12 "LLS offered $\times$ In-game savings"  withllsa_loto12  "LLS offered $\times$ In-game lotto"
	withllsa_discount "LLS offered $\times$ Discount rate" withllsa_presbias "LLS offered $\times$ Present bias" 
	withllsa_sigma_std "LLS offered $\times$ Risk loving" withllsa_alpha_std "LLS offered $\times$ Probability weighting"
	withllsa_lotoinvest "LLS offered $\times$ Play loto for investment" withllsa_lotogoal "LLS offered $\times$ Play loto for goal"
	_cons "Mean, LLS not offered") 
	mlabels ("Total savings" "Total savings" "Total savings" "Total savings" "Total savings")
	nonotes addnotes("Notes: Total savings is defined as the total secured principal received in eight weeks. 
	The following variables are transformed into its standard normal version: risk loving, and probability weighting. 
	Robust standard errors clustered by individuals are shown in parentheses. 
	Level of significance: *** p<0.01, ** p<0.05, * p<0.10.");	
	#delimit cr
	

*END OF DO FILE*	
